package org.example.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.ourEnum.ExhibitionStatus;
import org.example.pojo.domain.Exhibition;

import java.util.Date;
import java.util.List;

@Mapper
public interface ExhibitionMapper {
    Exhibition selectById(@Param("exhibitionId") Integer exhibitionId);

    List<Exhibition> selectAll();

    List<Exhibition> selectPublished();

    Integer insert(Exhibition exhibition);

    Integer update(Exhibition exhibition);

    Integer deleteById(@Param("exhibitionId") Integer exhibitionId);

    List<Exhibition> searchByName(@Param("title") String title);

    @Select("SELECT COUNT(*) FROM exhibitions WHERE start_time <= CURDATE() AND end_time >= CURDATE()")
    int countEventsToday(Date date);

    void changeStatus(@Param("id") Integer exhibitionId, @Param("status") ExhibitionStatus published);

    List<Exhibition> findAvailableExhibitions();

}
